/*
 * To change this template, choose Tools | Templates,
 * and open the template in the editor.
 */
package com.kedacom.demo.scriptEngine;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author xiaojinghai
 */
public class HelloWorld {

    private static final Logger logger = LoggerFactory.getLogger(HelloWorld.class);

    public static void main(String[] args) throws FileNotFoundException, ScriptException {
        String groovyScriptFile = "src/test/resources/HelloWorld.groovy";
        String javaScriptFile = "src/test/resources/HelloWorld.js";

        FileReader scriptReader = new FileReader(new File(javaScriptFile));
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("js");
        engine.eval(scriptReader);
    }
}
